<!DOCTYPE HTML>
<html>
<head th:replace="mgr/base/head :: head('metaweblog配置')"></head>
<body>
	<nav th:replace="mgr/base/nav :: active('config-metaweblogConfig')"></nav>
	<div id="page-wrapper" style="padding: 10px">
		<div class="container-fluid">
			<div class="row" style="padding: 5px">
				<div class="col-md-6 col-md-offset-3">
					<div class="tip" style="margin-top: 10px"></div>
					<form method="post" id="matweblogConfigForm">
						<div class="form-group">
							<label>上传路径</label><input type="text" class="form-control" name="path" th:value="${config.path}"/>
						</div>
						<input type="hidden" th:if="${config.store != null}" th:value="${config.store}" id="store"/>
						<div class="form-group" id="stores" style="display:none">
							
						</div>
						<button type="button" id="update" class="btn btn-default">修改配置</button>
					</form>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="base/foot_source"></div>
	<script>
	var stores = [];
	$.ajax({
		type : "get",
		url : basePath+"/mgr/file/stores",
        contentType:"application/json",
		data : {},
		success : function(data){
			var html = "";
			html += ('<select name="store" id="stores-select" class="form-control">');
			for(var i=0;i<data.length;i++){
				html += ('<option  value="'+data[i].id+'">'+data[i].name+'</option>');
			}
			html += ('</select>');
			$("#stores").html(html).show();
			if($("#store").length > 0){
				var store = $("#store").val();
				$('#stores-select').val(store);
			}
		},
		complete:function(){
		}
	});
	$("#update").click(function() {
		var data = $("#matweblogConfigForm").serializeObject();
		$.ajax({
			type : "post",
			url : basePath + "/mgr/config/metaweblogConfig/update",
			data : JSON.stringify(data),
			dataType : "json",
			contentType : 'application/json',
			success : function(data) {
				if (data.success) {
					success(data.message);
				} else {
					error(data.message);
				}
			},
			complete : function() {
				$("#update").prop("disabled", false);
			}
		});
	});
	</script>
</body>
</html>
